import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

/**
 * @author gao
 * @date 2025/10/22 14:20
 */

public class Solution {
    public int nthUglyNumber(int n) {
        PriorityQueue<Long> heap = new PriorityQueue<>();
        Set<Long> seen = new HashSet<>();

        heap.offer(1L);
        seen.add(1L);

        long[] factors = {2, 3, 5};
        long ugly = 1;

        for (int i = 0; i < n; i++) {
            ugly = heap.poll();

            for (long factor : factors) {
                long next = ugly * factor;
                if (!seen.contains(next)) {
                    seen.add(next);
                    heap.offer(next);
                }
            }
        }
        return (int) ugly;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            Solution solution = new Solution();
            System.out.println(solution.nthUglyNumber(n));
        }
    }
}